New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adjust js guard behavior #317
Conversation
src/rules/util.js
Outdated
'xit', | ||
'xtest', | ||
]); | ||
export const testCaseNames = new Set(['fit', 'it', 'test', 'xit', 'xtest']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to export this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to verify, test.only
is still detected, yeah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point about the export - I'll check it right now.
Definitely still catches test.only
, b/c otherwise no-focused-tests
would fail :)
All of the places that actually do something specific for things like only
& skip
actually implement their own checks; which makes sense b/c there's no way to explicitly get them out of the Set
.
That's why it all still works, b/c the sets & guards are meant to serve as a way to know if you're in the "jest domain" (and so if you should bother checking anything at all), rather than for explicit "is it this specific jest method".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass with less code - I'm happy 🙂
🎉 This PR is included in version 22.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This changes the behaviour of the js guard functions (
isHook
,isTestCase
, andisDescribe
) to match the TS behaviour in #316Currently only
CallExpression
s whose entire member chain is described in the relatedSet
are considered to be "X" (where "X" is a hook, test case, or describe depending on whichis<x>
method is called).For example, this means that
describe.only.each
isn't considered adescribe
byisDescribe
.This PR changes that behaviour to just the first member in the chain for if they're in the related
Set
.Neither behaviour is strictly right or wrong, but this behavioural change currently exists in the TS branch, and so a change has to happen somewhere.
The new behaviour doesn't cause any tests to fail (aside from in
no-if
, which has been fixed), so it could be merged & released to get a scope on what the impact of this change will be.